home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / newsgroups / misc.20000824-20010305 / 000213_news@columbia.edu _Thu Jan 18 07:43:18 2001.msg < prev    next >
Internet Message Format  |  2020-01-01  |  17KB

  1. Return-Path: <news@columbia.edu>
  2. Received: from watsun.cc.columbia.edu (watsun.cc.columbia.edu [128.59.39.2])
  3.     by monire.cc.columbia.edu (8.9.3/8.9.3) with ESMTP id HAA11610
  4.     for <kermit.misc@cpunix.cc.columbia.edu>; Thu, 18 Jan 2001 07:43:18 -0500 (EST)
  5. Received: from newsmaster.cc.columbia.edu (newsmaster.cc.columbia.edu [128.59.59.30])
  6.     by watsun.cc.columbia.edu (8.8.5/8.8.5) with ESMTP id HAA05517
  7.     for <kermit.misc@watsun.cc.columbia.edu>; Thu, 18 Jan 2001 07:43:18 -0500 (EST)
  8. Received: (from news@localhost)
  9.     by newsmaster.cc.columbia.edu (8.9.3/8.9.3) id HAA03261
  10.     for kermit.misc@watsun.cc.columbia.edu; Thu, 18 Jan 2001 07:18:02 -0500 (EST)
  11. X-Authentication-Warning: newsmaster.cc.columbia.edu: news set sender to <news> using -f
  12. From: <Use-Author-Address-Header@[127.1]>
  13. Subject: Case Study: Lynx/Kermit Coordination Part I
  14. Message-ID: <E14JDxu-0000nb-00@dxmcgyver>
  15. Date: Thu, 18 Jan 2001 04:14:54 -0800
  16. Organization: mail2news@nym.alias.net
  17. To: kermit.misc@columbia.edu
  18.  
  19.  
  20. Lynx/Kermit Coordination Part I
  21.  
  22. The version of ckermit2.txt that I currently have,
  23. (http://www.columbia.edu/kermit/ckermit2.html#x1.3.2)
  24. in the Lynx section on invoking C-Kermit from your browser (1.3.2)
  25. it states that 'As far as we know, this can be done only at compile time.'
  26. If you consider what happens when you hit return to be 'invoking',
  27. stictly speaking this is true.
  28. *If* your version of Lynx is compiled with general External support,
  29. however, in your /etc/lynx.cfg file there should be some lines like:
  30.  
  31.  
  32. #***Must be compiled with USE_EXTERNALS to enable EXTERN ***
  33. KEYMAP:.:EXTERN                # Run external program with url
  34. #   or possibly:
  35. KEYMAP:,:EXTERN         # run EXTERNAL with URL.  added by d.e.l.
  36.  
  37.  
  38. Make sure one of these is uncommented (no preceeding '#'), 
  39. or add the lines if necessary.
  40. These should be located in a general set of Keymaps, with a lot of
  41. other similar statements.  The defaults may be commented out.
  42.  
  43. Later in the file there will be a section called EXTERNAL.
  44. (Note that it is 'EXTERN' in the Keymap section, but
  45. the commands are assigned in the 'EXTERNAL' section.)
  46.  
  47. There you should have some lines:
  48.  
  49. USE_EXTERNALS:TRUE
  50. EXTERNAL:ftp:FTP  %s &:TRUE
  51. #  Where FTP is created by:
  52. #  ln -s  kermit  FTP
  53. #  when kermit is C-Kermit 7.1+
  54. EXTERNAL:http:wget -P ~/download -q %s &:TRUE
  55. #  This could even be another browser for HTTPs, instead of wget
  56. EXTERNAL:telnet:kermit -J %s:TRUE
  57. EXTERNAL:iksd:kermit  %s:1649 :TRUE
  58. #  (or)
  59. EXTERNAL:iksd:IKSget  %s & :TRUE
  60.  
  61. The only ones needed for running kermit are the 'USE_EXTERNALS:TRUE'
  62. and the lines with kermit, iksd or FTP in them.  The other, I include 
  63. simply to show a typical other external program that could be 
  64. defined.  Again, make sure that there is no preceeding '#' on
  65. the line that would comment it out and render the line inoperative.
  66.  
  67. Now, when you hit return at a focused link, the default behavior of
  68. Lynx will result as typical - for instance if a 'telnet://aztec2.asu.edu'
  69. link the conventional and less capable telnet program will be invoked.
  70. If however, you hit '.' (or whatever you chose in the Keymap statement), 
  71. C-Kermit will be invoked instead.
  72. (Similarly, over an http link, '.' will in the case shown above
  73. invoke the wget program on an http URL.)
  74. Rather than a binary executable, the program specified by the
  75. EXTERNAL statement can be a shebang script ('#!/path/interpreter'
  76. on line 1), that could present a menu
  77. of options on how to handle the URL it is passed.
  78. This is possible because of how UNIX invokes external programs giving
  79. shebang scripts pretty much equality with binary executables.
  80. (Another possibility might be Frank de Cruz's 'IKSget' script.)
  81. My personal experience is that the program specification seemed 
  82. sensitve to trailing spaces, so a little bit of experimentation may
  83. be needed.
  84. EXTERNALs can be used to enable Lynx to cope with URL schema it has no
  85. compiled in basis to deal with.  For this reason I speculativly
  86. put the 'IKSD://'  (Internet Kermit Server Daemon) example above.
  87.  
  88. In keeping with the topic of Lynx/Kermit coordination then,
  89. I include the below Kerbang script that attempts to handle
  90. (or leave space for in the future) these variations of
  91. protocols to be called externally from Lynx.
  92. It's probably overkill, and some parts haven't been
  93. thoroughly tested yet (others have), 
  94. but it should handle my needs for a while.
  95. It allows you to switch to an alternate WWW 
  96. browser in mid-surfing session for interactive
  97. sessions, gives some options for IKSD and ftp if a file or path
  98. is specified, or hops to C-Kermit if appropriate.
  99. Keep in mind that this is a work in progress,
  100. but is what I currently use.
  101.  
  102.  
  103. #!/usr/local/bin/ck-7.1 +
  104.  
  105.  
  106. #  !/usr/local/bin/kermit +
  107.  
  108. #  lynxbooster.ksc
  109. #    script for external programs for Lynx web browser
  110. #  ( by D. E. Legan, 18 Jan. 2001 )
  111.  
  112. #  Requires:  Lynx, C-Kermit 7.1, IKSget and whatever suplemental
  113. #             http user agents/browsers desired.
  114.  
  115. #  According to the Lynx documentation, it can handle
  116. #  an URL of form:
  117.  
  118. #  telnet://user:password@host:port
  119.  
  120. #  and also can handle rlogin, tn3270, tn5250 protocols similarly
  121.  
  122. #  Reading over the Lynx documentation for ftp URLs
  123. #  it can handle a form of:
  124.  
  125. #  ftp://user@host:port/path;type=[D,I,orA]
  126. #  (D,I,A = directory, binary or ASCII)
  127.  
  128. #  where user might be broken down to actually be
  129. #  a user:password.  if this followed average ftp
  130. #  conventions, then it might actually be:
  131.  
  132. #  ftp://username:user@homehost@remotehost:port/path;type=[D,I,orA]
  133.  
  134. #  Personally, I've never seen the ';type=...' part of the URL,
  135. #  so for the time being, I will ignore it, but will allot for
  136. #  some of the other complications.
  137. #  For using C-Kermit 7.1 ftp personality,  
  138. #  a soft link named 'FTP' has been made to the executable,
  139. #  to distinguish it from the plain vanilla conventional
  140. #  ftp executable.
  141.  
  142. # USAGE:
  143. #     In the lynx configuration file (typicly, lynx.cfg
  144. #     or lynx-ssl.cfg) there should be some lines
  145. #     like the following (not commented with '#' in column 1 
  146. #     though :-) ) to activate this program:
  147. #     
  148. #KEYMAP:,:EXTERN         # run EXTERNAL with URL.  added by d.e.l.
  149. #...........
  150. #USE_EXTERNALS:TRUE
  151. #...........
  152. #EXTERNAL:ftp:lynxbooster.ksc %s:TRUE
  153. #EXTERNAL:http:lynxbooster.ksc %s:TRUE
  154. #EXTERNAL:telnet:lynxbooster.ksc %s:TRUE
  155. #EXTERNAL:rlogin:lynxbooster.ksc %s:TRUE
  156. #EXTERNAL:tn3270:lynxbooster.ksc %s:TRUE
  157. #EXTERNAL:tn5250:lynxbooster.ksc %s:TRUE
  158. #EXTERNAL:iksd:lynxbooster.ksc %s:TRUE
  159.  
  160. # If not already defined, the KEYMAP value (in this case ',')
  161. # should be chosen so as not to conflict with other Lynx control
  162. # keys.
  163. # When over a link to one of these protocols, hit this key
  164. # instead of return to activate this script for the link.
  165. # The EXTERNAL statements define the protocols that external 
  166. # commands will be available for (in this case,
  167. # ftp, http, telnet, rlogin, tn3270 tn5250 and iksd), and the 
  168. # program to be run for them (in this case this script.)
  169.  
  170. # Note that if any external programs are called for
  171. # 'telnetish' protocols via pty/pipe/exec,
  172. # they may require adjustments of this script.
  173.  
  174.  
  175. #  Variables:
  176. #  \%a - address of URL
  177. #  \%b - user input selection flag
  178. #  \%d - raw URL
  179. #  \%f - file name stripped of directory
  180. #  \%i - path/file
  181. #  \%p - port number
  182. #  \%q - path
  183. #  \%r - protocol this script is being used for
  184. #  \%t - index used in parsing the URL as specified above
  185. #  \%u - user ID
  186. #  \%w - password
  187.  
  188.  
  189. echo {LYNX_VERSION = \$(LYNX_VERSION)}
  190. #  According to Lynx man pages, this variable is always set by Lynx
  191.  
  192. set case off
  193.  
  194. # First let's pick apart the URL for possibly usefull parts
  195.  
  196. \%d := \%1
  197. \%a := \%d
  198. \%r := \%a
  199.  
  200. # strip the protocol from the URL: 
  201. \%a := \Flop(\%a,:)  ;  strip off up to '://'
  202. \%a := \Fltrim(\%a,/)
  203.  
  204. # extract the protocol, up to '://':
  205. \%r := \Freplace(\%r,://\%a,)
  206.  
  207. #  First, we set up any URL protocol specific items:
  208. #  (this section is largely an artifact of development process
  209. #  but left in for future complications.)
  210. switch \%r {
  211.   :telnet, 
  212.   :rlogin,
  213.   :ftp, 
  214.   :http, 
  215.   :iksd,
  216.     #  this version, not much really needed here yet.  :-)
  217.     .\%c := kermit
  218.     break
  219.  
  220.     #  I haven't actually seen any mention of the 
  221.     #  next five URL types yet, but what the heck.....
  222.   :ssh,
  223.   :telnet-ssl,
  224.   :s5telnet,
  225.   :ktelnet,
  226.   :srp-telnet,
  227.     
  228.     #  Back to reality:
  229.   :tn3270,
  230.   :tn5250,
  231.   :default,
  232.     #  included for future generalization of this script
  233.     echo  \%r protocol currently not supported.
  234.     ask  \%z  Press enter to continue
  235.     quit
  236.     .\%c = {pty \%r   }
  237.     .\%s :=  {  }
  238.     break
  239. }
  240. # Finished handling URL protocol specific stuff
  241.  
  242.  
  243. # Check to see if a directory/filename is on the end of the URL
  244. # indicates that this is a particular file to be downloaded from an IKSD:
  245.  
  246. \%i := /\Flop(\%a,/)          #  i holds the path/filename
  247. \%a := \Freplace(\%a,\%i)     #  a holds usrid:password@host.domain:port
  248.  
  249. # extract filename:
  250. \%f := \Freplace(\%i,\Fstripx(\%i,/),)   #  f has the directory removed
  251. \%f := \Fltrim(\%f,/)                    #  now f has any '/' trimmed off
  252. \%q := \Freplace(\%i,\%f,)               #  q holds just the path name
  253.  
  254.  
  255.  
  256. # Now handle 'User:password' part of URL:
  257.  
  258. # find  the '@'s location in the URL:
  259. \%t := \Findex(@,\%a)
  260. #  Definitly set defaults for user and password:
  261. \%u := { }
  262. set login userid
  263. \%w := { }
  264.  
  265. if > \%t 0 {
  266.   #  extract and clean up the 'usrid:password':
  267.   .\%u := \Fstripx(\%a,@)
  268.   #  extract and clean up the 'host.domain:port':
  269.   .\%a := \Flop(\%a,@)
  270.   .\%a := \Flop(\%a,@)    #  the ftp two '@' case
  271.   # is there a password?
  272.   .\%t := \Findex(:,\%u)
  273.   #  Now seperate the user id from the password if present:
  274.   if > \%t 0 {
  275.     .\%w := \Flop(\%u,:)
  276.     .\%u := \Fright(\%u,\%t)
  277.     .\%u := \Ftrim(\%u,:)
  278.   }
  279.   # For kermit:
  280.   set ftp autologin on
  281.   set ftp user \%u \%w
  282.   set login userid \%u
  283. }
  284. # Finished extracting user/password
  285.  
  286.  
  287. # Now handle any port part of the URL:
  288. \%p := { }
  289. # Is there a port specified?
  290. \%t := \Findex(:,\%a)    #    'host.domain:port' are divided at \%t index
  291.  
  292. # Now, if a port was specified:
  293. if > \%t 0  {
  294.   .\%p := \Flop(\%a,:)
  295.   .\%a := \Freplace(\%a,\%p,)
  296.   if equal \%p kermit  .\%p := 1649
  297.   .\%a := \Ftrim(\%a,:)
  298.   if equal \%r telnet  if equal \%p 1649  -
  299.     if not equal {\%i} {} {
  300.     #  this case is really not interactive, but in fact IKSD
  301.     #  to a specific file
  302.     .\%r := IKSD
  303.   }
  304. }
  305. # End of handling port number
  306.  
  307.  
  308. # Handle HTTP/interactive selections here:
  309.  
  310. # Make this script do double duty, by putting the following line
  311. # in the printer setup part of the your Lynx configuration file.
  312. # Then you can pass the URL of the currently viewed page
  313. # (not just the currently active link) to other browsers:
  314.  
  315. #  PRINTER:View URL with other browser:exec /path/lynxbooster.ksc ${LYNX_PRINT_URL}:TRUE
  316.  
  317. # (hit the 'p' key, and select 'View URL with other browser' to bring
  318. # up this menu.)
  319. # Check the Lynx man pages for information on environmental variable
  320. # LYNX_PRINT_URL.
  321.  
  322. if equal \%r http  {
  323.  
  324.   #    This part should be adjusted for whatever suplemental
  325.   #    HTTP tools you want to use.
  326.  
  327.   if equal {\%f} {}    .\%f := \%a
  328.   clear screen
  329.   #  -- try to keep this screen formating/menu simple and uncluttered
  330.   :wwwchoice
  331.   echo 
  332.   echo To connect to \%a\, choose an alternate browser:
  333.   echo  
  334.  
  335.   #  most of these are frame-capable browsers
  336.   #  (Lynx barely handles frames.):
  337.  
  338.   echo {  N  Netscape}
  339.   echo {  W  w3m}
  340.   echo {  L  Links}
  341.   echo {  D  Debris}
  342.  
  343.   #  Warning about Debris:  I'm certain it will be great when complete,
  344.   #  but it is a work in progress.  My experience is that
  345.   #  if you notice this script flashin on the screen and aborting
  346.   #  before you can do anything, you may of called Debris once too often.
  347.   #  :-)
  348.  
  349.   #  and a few methods of dumping files/directories
  350.   #  in background:
  351.  
  352.   echo {  Y  Lynx/dump in background}
  353.   echo {  R  Wget/recurse in background}
  354.   echo {  X  Exit back to Lynx}
  355.   #  echo {  E Etc.........}
  356.  
  357.   #  Could have Lynx with some drasticly different configuration
  358.   #  file listed in here, maybe special provisions for handling
  359.   #  cookies.
  360.   
  361.  
  362.  
  363.  
  364.   echo  
  365.   ask \%b {Alternate browser choice: }
  366.   echo  \%b
  367.  
  368.   switch \%b  {
  369.  
  370.     :N,  exec  netscape \%d
  371.          break
  372.  
  373.     :W,  exec  w3m  -M  -F -no-cookie -no-mouse   \%d
  374.          break
  375.   
  376.     :L,  exec  links   \%d
  377.          break
  378.   
  379.     :D,  exec  debris   \%d
  380.          break
  381.   
  382.     :Y,  run  lynx -source  \%d  >  \%f  &
  383.          #  May want to put cookie handling capabilities
  384.          #  with the above command
  385.          #  or maybe nohup this to direct the output
  386.          #  away from the screen
  387.          break
  388.   
  389.     :R,  run  wget -D \%a -P \v(download) -np -brkl5  \%d
  390.          break
  391.          # -D \%a          - restricted to  \%a domain
  392.          # -P \v(download) - put in download directory
  393.          # -np             - no parent directories
  394.          # -b              - go to background
  395.          # -r              - download recursively
  396.          # -k              - 'konvert' to relative links
  397.          # -l5             - limit to just 5 levels of recursion
  398.   
  399.     :X,  break       #  exit back to Lynx
  400.  
  401.   
  402.     :default,  echo {Invalid choice, try again}, goto wwwchoice
  403.   }
  404.   quit
  405.  
  406. }
  407. # end of HTTP/interactive selection 
  408.  
  409. if not equal {\%p} { }  .\%p := :\%p
  410. else .\%p := 
  411.  
  412.  
  413. #  If a specific directory/file is defined to retreive, hop to
  414. #  non-interactive options
  415. #  if not equal {\%i} {}  forward IKSgfile
  416. #   temp (X) :  set ftp autologin on
  417. if not equal {\%f} {}  forward IKSgfile
  418.  
  419.  
  420. # No file is specified
  421. #  if equal  \%r ftp    exec  FTP  -S  \%d
  422. if equal  \%r ftp  {
  423.   if not equal {\%w} { }   exec  FTP  -u \%u -P \%w -S  -D  \%q  \%a  \%p
  424.   if not equal {\%u} { }   exec  FTP  -u \%u        -S  -D  \%q  \%a  \%p
  425.                            exec  FTP  -A            -S  -D  \%q  \%a  \%p
  426. }
  427.  
  428.  
  429. if equal \%r iksd  {
  430.   if equal {\%w} { }  .\%w := \v(userid)@\v(host)
  431.   if equal {\%u} { }  .\%u := anonymous
  432.  
  433.   #  It seems to work best for me if normal initialization
  434.   #  is carried out before making an IKSD connection
  435.   #  and so an init files are read
  436.   take ~/.mykermrc
  437.  
  438.   iksd telnet://\%a\%p
  439.   remote login \%u \%w
  440.   remote cd \%i
  441.   forward  the_end
  442. }
  443.  
  444.  
  445. #  Parts from here to ':IKSgchoice' will probably need modification
  446. #  if any protocols that actually use pty/pipe external
  447. #  programs are used.
  448.  
  449.  
  450.  
  451. # So if a password was given:
  452. if not equal {\%w} { } {
  453.   echo {  Remember, in the URL}
  454.   echo {  the fools gave you this password: \%w}
  455.   ask \%z  Press any key to continue
  456. }
  457.  
  458.  
  459. # If a userid was given:
  460. if not equal {\%u} { } {
  461.   exec kermit -M \%u \%r://\%a\%p\%i
  462.   forward  the_end
  463. }
  464.  
  465.  
  466. # If no userid was part of the URL:
  467.  
  468. exec kermit  -J \%r://\%a\%p\%i
  469. forward  the_end
  470.  
  471.  
  472.  
  473.  
  474.  
  475.  
  476.  
  477.  
  478. #  Here handle getting a specific file:
  479. :IKSgfile
  480.  
  481. clear screen
  482. #  -- try to keep this screen formating/menu simple and uncluttered
  483. :iksgchoice
  484. echo 
  485. echo To connect to \%a and retreive \%i, 
  486. echo using \%r protocol, choose a mode:
  487. echo  
  488. echo {  F  Foreground - 'I like to watch'}
  489. echo {  B  Background - 'My time is precious'}
  490. echo {  X  Exit       - 'I need to do something else'}
  491. #  echo   :b,  run  ck-7.1   \%r://\%a\%p\%i  &
  492. echo  
  493. echo d is \%d
  494. echo r is \%r
  495. ask \%b {Job mode choice: }
  496. echo  \%b
  497.  
  498. switch \%b  {
  499.   :f,  if equal \%r ftp  {
  500.          exec FTP   \%d   
  501.               #  Using C-Kermit 7.1 FTP personality
  502.          break
  503.        } 
  504.        exec  IKSget \%d &
  505.        #  May want to nohup this to control output 
  506.        break
  507.   :b,  if equal \%r ftp  {
  508.          run  FTP   \%d  &    #  Again, Using C-Kermit 7.1's FTP personality
  509.          #  May want to nohup this to control output 
  510.          #  otherwise may need to ^L to refresh screen as
  511.          #  messages arrive from the background
  512.          break
  513.        }
  514.        run  IKSget \%d &
  515.        #  ditto the above ftp comments
  516.        break
  517.   :x,  break
  518.   :default,  echo {Invalid choice, try again}, goto iksgchoice
  519. }
  520.  
  521. forward the_end
  522.  
  523.  
  524. :the_end
  525.  
  526. quit
  527.  
  528.  
  529. Thanks to everyone at the Kermit center for the help they've
  530. provided many times.
  531.  
  532. Regards,
  533. Dallas E. Legan II  
  534. l  \  d
  535.  e  \  a
  536.   g  \  l
  537.    a  \  l
  538.     n  \  a
  539.      i  \  s
  540.       i  \  i
  541.        @  \  @
  542.         s  \  k
  543.          u  \  i
  544. Parse     r  \  n
  545. this       f  \  c
  546. SpamBots!   r  \  y
  547.              e  \  b
  548.               e  \  .
  549.                .  \  c
  550.                 c  \  o
  551.                  o  \  m
  552.                   m